import {dbInstance} from '../db/config'
export default class getAllOrdersController{
  // 返回当前表所有的数据的方法
  // 登录时只需验证表中是否有该username且password完全对应
  async getAllOrders(payload){
    console.log(payload);
    let {username}=payload
    const[ orderList, metadata]=await dbInstance.query(`SELECT b.id from users a join orders b on a.id = b.UserId where username = ${username}`)
    console.log(orderList);
    const allOrders=[]
    for(let index in orderList){
       allOrders.push(await dbInstance.query(`call selectAllOrders(${orderList[index].id})`))
    }
    console.log("找到所有订单",allOrders);
    return allOrders;
  }
}